﻿<%@ WebHandler Language="C#" Class="UploadFleetHandler" %>

using System;
using System.Web;
using System.IO;
using System.Data;
using System.Text;
using System.Collections;
using System.Data.SqlClient;

using CE.Database;
using CE.InputOut;

public class UploadFleetHandler : IHttpHandler 
{
    
    public void ProcessRequest(HttpContext context)
    {
        context.Response.Clear();

        if (context.Request["fileName"] != null)
        {
            string _filePath = context.Request.QueryString["fileName"].ToString();

            string filePath = _filePath;
            FileInfo file = new System.IO.FileInfo(filePath);
            if (!file.Exists)
            {
                context.Response.StatusCode = 500;
                context.Response.End();
                return;
            }
            context.Response.Clear();
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.Cache.SetNoStore();
            context.Response.Cache.SetExpires(DateTime.MinValue);
            context.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
            context.Response.AddHeader("Content-Length", file.Length.ToString());
            context.Response.ContentType = "application/octet-stream";
            context.Response.WriteFile(file.FullName);
            context.ApplicationInstance.CompleteRequest();
            context.Response.End();

        }
    }
 
    public bool IsReusable 
    {
        get 
        {
            return false;
        }
    }

}